package com.leapp.sk.viewdelegate.personal

import android.text.TextUtils
import android.widget.ListView
import com.example.mvp.delegate.BaseAppDelegate
import com.example.mvp.view.SKTopBar
import com.leapp.sk.R
import com.leapp.sk.bean.ConcatTeacherDataEntity
import com.leapp.sk.bean.ContanctThecherEntity
import com.leapp.sk.ui.activity.personal.ContactTecherActivity
import com.leapp.sk.ui.activity.personal.PersonalDataActivity
import com.leapp.sk.ui.adapter.ContactTecherAdapter

/**
 * 联系老师
 * @author  chaohaipeng  on 2018/8/8.
 */
class ContactTecherDelegate : BaseAppDelegate() {
    /**
     * 联系老师适配器
     */
    private var mAdapter: ContactTecherAdapter? = null

    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_contanct_techer
    }

    fun initAdapter(mlist: List<ConcatTeacherDataEntity>) {
        val lv_act_contanct_list = getView<ListView>(R.id.lv_act_contanct_list)
        mAdapter = ContactTecherAdapter(getActivity(), mlist)
        lv_act_contanct_list.adapter = mAdapter
    }

    /**
     * 刷新适配器
     */
    fun notifyAdapter() {
        mAdapter?.notifyDataSetChanged()
    }

    /**
     * 设置标题栏
     */
    fun setTitle(title: String?) {
        val jtb_act_contanct = getView<SKTopBar>(R.id.jtb_act_contanct)
        if (!TextUtils.isEmpty(title)) {
            jtb_act_contanct.setTitle(title)
        }
        setEvent(jtb_act_contanct)
    }

    /**
     * 设置设置事件
     */
    fun setEvent(topBar: SKTopBar) {
        topBar?.setEventInterface(object : SKTopBar.EventInterface {
            override fun leftOnClick() {
                getActivity<ContactTecherActivity>().finish()

            }

            override fun rightOnClick() {
            }

        })
    }

}